package com.mingzhi.product.controller;

import com.mingzhi.product.bean.Product;
import com.mingzhi.product.service.ProductService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/product")
public class ProductController {

    @Autowired
    private ProductService productService;

    /**
     * 获取商品信息
     *
     * @param id 商品ID
     * @return 商品信息
     */
    @GetMapping("/{id}")
    public Product getProductInfo(@PathVariable("id") Long id,
    HttpServletRequest request) {
        System.out.println("mingzhi ......." + "【Token】=" + request.getHeader("X-Token"));
        Product product = productService.getProductById(id);
        return product;
    }
}
